//
//  RW_HomeViewModel.m
//  SleepApp
//
//  Created by MAC on 2021/3/19.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_HomeViewModel.h"
#import "RW_HomeItemView.h"

@implementation RW_HomeViewModel


#pragma mark -- 视图模型获取
/** 获取歌曲详情 */
-(void)getNavcatSuccess:(void(^)(NSArray<WLNavigationScrollModel *> *response))success
                fail:(void(^)(NSError *error))fail{
    [[[RW_SingleModel getSingleList] then:^id _Nullable(NSArray<RW_SingleModel *> * _Nullable value) {
        if (success){
            success([self getNavigationModelList:value]);
        }
        return nil;
    }] catch:fail];
}


#pragma mark -- 视图模型组合
-(NSArray<WLNavigationScrollModel *> *)getNavigationModelList:(NSArray<RW_SingleModel *> *)singleList{
    NSMutableArray *array = [NSMutableArray array];
    for (RW_SingleModel *single in singleList){
        WLNavigationScrollModel *nav = [[WLNavigationScrollModel alloc]init];
        nav.title = single.name;
        nav.viewClassType = @"1";
        
        nav.contentClass = RW_HomeItemView.class;
        nav.data = single;
        
        [array addObject:nav];
    }
    return array;
}
@end
